#pragma once

#include <gofcl_rcu_ahb.h>
#include <gofcl_rcu_r.h>

// AHBEN寄存器第0到15位的定义
typedef struct {
	rcu_ahb_0_7_s ahben_0_7;
	rcu_ahb_8_15_s ahben_8_15;
} __attribute__((aligned(2))) rcu_ahben_s;

_Static_assert(sizeof(rcu_ahben_s) == 2, "Struct rcu_ahben_s defined error!");

// 设置AHBEN寄存器的值
static inline void rcu_wreg_ahben_s(rcu_ahben_s ahb) {
	union {
		rcu_ahben_s a;
		u32_s u;
	} au = {
		.a = ahb,
	};
	rcu_wreg_u16(RCU_AHBEN_R, T16B_0_R, au.u);
}

// 设置AHBEN寄存器第0到7位的值
static inline void rcu_wreg_ahben_0_7_s(rcu_ahb_0_7_s ahb_0_7) {
	union {
		rcu_ahb_0_7_s a;
		u32_s u;
	} au = {
		.a = ahb_0_7,
	};
	rcu_wreg_u8(RCU_AHBEN_R, T8B_0_R, au.u);
}

// 设置AHBEN寄存器第8到15位的值
static inline void rcu_wreg_ahben_8_15_s(rcu_ahb_8_15_s ahb_8_15) {
	union {
		rcu_ahb_8_15_s a;
		u32_s u;
	} au = {
		.a = ahb_8_15,
	};
	rcu_wreg_u8(RCU_AHBEN_R, T8B_1_R, au.u);
}
